package com.applet.applet_shangcheng.dao;

import com.applet.applet_shangcheng.entity.IntegralOrder;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

@Mapper
public interface IntegralOrderMapper {
    int getHasPay(@Param("month")String month);

    int getNotPay(@Param("month")String month);
    @Insert({
            "insert into tb_integral_order (order_id,order_name,sum_number,sum_price,create_time,pay_time,username,consignee,phone,consignee_address,order_status,pay_status,emission_status,pay_mode) values (#{orderId},#{orderName},#{sumNumber},#{sumPrice},#{createTime},#{payTime},#{username},#{consignee},#{phone},#{consigneeAddress},#{orderStatus},#{payStatus},#{emissionStatus},#{payMode})"
    })
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int insertOrder(IntegralOrder integralOrder);

    @Update({
            "update from tb_integral_order set order_id=#{orderId},order_name=#{orderName},sum_number=#{sumNumber},sum_price=#{sumPrice},create_time=#{createTime},update_time=#{updateTime},pay_time=#{payTime},emission_time=#{emissionTime},delivery_name=#{deliveryName},delivery_number=#{deliveryNumber},username=#{username},consignee=#{consignee},phone=#{phone},consignee_address=#{consigneeAddress},order_status=#{orderStatus},pay_status=#{payStatus},emission_status=#{emissionStatus},pay_mode=#{payMode} where id = #{id}"
    })
    int updateOrder(IntegralOrder integralOrder);

    @Select({
            "select id,order_id,order_name,sum_number,sum_price,create_time,update_time,pay_time,emission_time,delivery_name,delivery_number,username,consignee,phone,consignee_address,order_status,pay_status,emission_status,pay_mode from tb_integral_order where username=#{username}"
    })
    List<IntegralOrder> findAll(@Param("username") String username);

    @Select({
            "select id,order_id,order_name,sum_number,sum_price,create_time,update_time,pay_time,emission_time,delivery_name,delivery_number,username,consignee,phone,consignee_address,order_status,pay_status,emission_status,pay_mode from tb_integral_order where order_id=#{orderId}"
    })
    IntegralOrder findById(@Param("orderId") String orderId);

    @Delete({
            "delete from tb_integral_order where id =#{id}"
    })
    int deleteOrder(@Param("id") int id);

    Page<IntegralOrder> findAlls(String queryString);

    @Select({
            "select * from tb_integral_order where id =#{id}"
    })
    IntegralOrder integralOrder(String id);

    @Update({
            "update tb_integral_order set order_id=#{orderId},order_name=#{orderName},sum_number=#{sumNumber},sum_price=#{sumPrice},create_time=#{createTime},update_time=#{updateTime},pay_time=#{payTime},emission_time=#{emissionTime},delivery_name=#{deliveryName},delivery_number=#{deliveryNumber},username=#{username},consignee=#{consignee},phone=#{phone},consignee_address=#{consigneeAddress},order_status=#{orderStatus},pay_status=#{payStatus},emission_status=#{emissionStatus},pay_mode=#{payMode} where id =#{id}"
    })
    int updateOrder1(IntegralOrder integralOrder);

    @Select({"select sort_name,sort_id from tb_integral_malls where table_t = tb_integral_goods"})
    List<Map<String, String>> getGoodsClass();
}












